home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10040 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.6 KB

  1. Path: osiris.ivy-ops.orbis.net!NewsWatcher!user
  2. From: kempkec@multiad.com (Christopher Kempke)
  3. Newsgroups: comp.lang.c++
  4. Subject: How to shrink your Windows program by %80!
  5. Date: 5 Mar 1996 20:50:32 GMT
  6. Organization: Multi-Ad Services, Inc.
  7. Message-ID: <kempkec-0503961448550001@205.164.77.10>
  8. NNTP-Posting-Host: 205.164.77.10
  9.  
  10. Richard Champalbert writes:
  11. > How is that possable? Convert it to Pascal.
  12. > Does anybody use Turbo Pascal (TP) for Windows? Having used only
  13. > BorlandC++ (BC) for Windows for the past few years, I was amazed to see
  14. > how much faster TP compiled and how much smaller the resulting code was.
  15. > If you have these two products try out a simple experiment: Write the
  16. > "hello world. program for Windows" with each compiler, then look and see.
  17. > When I compiled with TP I thought that the compilation had stopped on an
  18. > error, but no, it was just _very_ fast. In my particular case I wrote a
  19. > very simple program to write a few lines of text in a window; a simple
  20. > task that I wanted to spend as little time writing as possible, so I used
  21. > OWL for BC, and the equivilent for TP.
  22. > The size comparison: BC - 90k,    TP - 14k!
  23. > The two programs do _exactly_ the same thing.
  24.  
  25. No, they probably don't, as is clear from the fact that they're not the
  26. same size.  Their _output_ is the same, which isn't the same thing at
  27. all.  What you're seeing here is the difference in overhead between a
  28. pascal program and a C++ program.   C++ is a more powerful language than
  29. Pascal, so it has more "setup."   The difference in language complexity is
  30. also probably why Pascal compiles faster.  From a compiler writer's
  31. standpoint, Pascal isn't just a simpler language than C++, it's a _MUCH
  32. SIMPLER_ language.
  33.  
  34. What's especially deceptive about these numbers is that they are on such a
  35. small program.  The 90K vs. 14K difference is vast, but 590K vs 514K
  36. wouldn't be,
  37. and I suspect (without proof, I'm primarily a Mac programmer) that the
  38. size difference doesn't magnify with the size of your program. Further,
  39. the Pascal program would almost certainly be larger, since one of the
  40. advantages of good C++ programs is code re-use. 
  41.  
  42. [snip]
  43. > Why does one compiler seem to be so much more efficient than the other?
  44. > There is always the argument that "you get all the C++ goodies", but using
  45. > TP you can do just about everything that you can do in BC, with seamingly
  46. > increadable savings on final exe size.
  47.  
  48. Forgetting about Turing machines and universal models of computation and
  49. the like, let me state unequivocally that the above statement is false.
  50. C++ has built into it object-oriented and abstract data type abilities
  51. that Pascal can only dream of (even object-oriented Pascals).   While it
  52. is true that you could duplicate _all_ of this in Pascal (by writing a C++
  53. compiler in Pascal, for example, which is perfectly possible and has
  54. probably even been done), you'd find that building such structures would
  55. increase the program size well beyond what you'd get by having started
  56. with a language that supported them.
  57.  
  58. Bottom line - by using a more powerful language you can shrink the size of
  59. your code, but the cost is that the language itself becomes more
  60. expensive.  Pascal and C++ are actually pretty close to each other on this
  61. spectrum, compare Pascal to a 4th-Generation database language for
  62. example.  The 4GL is almost certainly easier to use, but enormously
  63. expensive in terms of resources to run.
  64.  
  65. Note that all of this is a generalization -- a bad pascal compiler might
  66. well produce larger executables than an excellent C++ compiler even on
  67. small programs.  But when the compilers are produced by the same company,
  68. probably even the same people, you have to believe language complexity is
  69. your culprit.
  70.